#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QtWidgets/QMainWindow>
#include "ui_mainwindow.h"

class Spreadsheet;
class FindDialog;
class GoToCellDialog;
class QLabel;
class QStringList;
class QString;
class QMenu;
class QAction;
class QToolBar;


class mainwindow : public QMainWindow
{
	Q_OBJECT

public:
	mainwindow(QWidget *parent = 0);
	~mainwindow();

private:
	Ui::mainwindowClass ui;
	Spreadsheet *m_pSpreadsheet;
	FindDialog *m_pFindDialog;
	QLabel *m_pLocationLabel;
	QLabel *m_pFormulaLabel;
	QStringList m_recentFiles;
	QString m_curFile;


	QMenu *m_pFileMenu;
	QMenu *m_pEditMenu;
	QMenu *m_pSelectSubMenu;
	QMenu *m_pToolsMenu;
	QMenu *m_pOptionsMenu;
	QMenu *m_pHelpMenu;
	
	QToolBar *m_pFileToolBar;
	QToolBar *m_pEditToolBar;

	QAction *m_pNewAction;
	QAction *m_pOpenAction;
	QAction *m_pSaveAction;
	QAction *m_pSaveAsAction;
	QAction *m_pSeparatorAtcion;
	enum {MaxRecentFiles = 5};
	QAction *m_pRecentFileActions[MaxRecentFiles];
	QAction *m_pExitAction;

	QAction *m_pCutAction;
	QAction *m_pCopyAction;
	QAction *m_pPasteAction;
	QAction *m_pDeleteAction;
	QAction *m_pSelectRawAction;
	QAction *m_pSelectColAction;
	QAction *m_pSelectAllAction;
	QAction *m_pFindAction;
	QAction *m_pGoToCellAction;

	QAction *m_pRecalculateAction;
	QAction *m_pSortAction;

	QAction *m_pShowGridAction;
	QAction *m_pAutoRecalAction;

	QAction *m_pAboutAction;
	QAction *m_pAboutQtAction;
protected:
	virtual void closeEvent(QCloseEvent *event);

private:
	void createActions();
	void createMenus();
	void createToolBars();
	void createStatusBars();
	void createDialogs();
	
	bool okToContinue();
	bool loadFile(const QString& filename);
	bool saveFile(const QString& filename);
	void setCurrentFile(const QString& fileName);
	QString strippedName(const QString& fullFileName);
	void updateRecentFileActions();
	void readSettings();
	void writeSettings();
public slots:
	void slotNewFile();
	void slotOpenFile();
	bool slotSaveFile();
	bool slotSaveAsFile();
	void slotOpenRecentFile();
	void slotExitAction();

	void slotCutAction();
	void slotCopyAction();
	void slotPasteAction();
	void slotDeleteAction();
	void slotSelectRawAction();
	void slotSelectColAction();
	void slotSelectAllAction();
	void slotFindAction();
	void slotGoToCellAction();

	void slotRecalculateAction();
	void slotSortAction();

	void slotShowGridAction(bool);
	void slotAutoRecalAction(bool);

	void slotAboutAction();
	void slotUpdateStatusBar();
	void slotSpreadsheetModifyed();


};

#endif // MAINWINDOW_H
